<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>resource-view-config-add</title>
	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/form.jsp"%>
  <script type="text/javascript">
  
  function add(){
	  //提交
	$.ajax({
		   type: "POST", 
		   url: "${pageContext.request.contextPath}/config/resource-view-config!save.action", //请求的action
		   data: $("#myform").serialize(), //传的参数
		   dataType: 'json',
		   success: function(data){ //结果
			   if(data == true){
				   var pWin = getTopWin(window).currentWin["add-resource-view-config"];
				   pWin.datagrid();
				
				   getTopWin(window).closejBox("add-resource-view-config");
			   }
			   
		   }
	});
	  
	  
  }
  $(function(){
	  $.formValidator.initConfig({formid:"myform"
          ,onerror:function(msg){}
          ,onsuccess:function(){
        	  		add();
          			return false;
          }
          });
	  $("#expandLevel").formValidator({onshow:"请输入数字 1-9",onfocus:"请输入数字 1-9",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"不能为空"}).inputValidator({min:1,max:1,onerror:"长度非法"})
	  .functionValidator({
			    fun:function(val,elem){
			    	 var reg = /^[0-9]+$/;
			    	    if(!reg.test(val)){
			    	        return "格式不正确";
			    	    }
			    	    return true;
				}
	  });
	  $("#name").formValidator({onshow:"请输入字符串  长度(1-64)",onfocus:"请输入字符串  长度(1-64)",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"不能为空"})
	  .functionValidator({
		    fun:function(val,elem){
		    	if(val.replace(/[ ]/g, "") == ''){
	    	    	return "不能为空字符串";
	    	    }
		    	    if(val.replace(/[^\x00-\xff]/g, "xx").length > 32){
		    	        return "长度超出最大范围";
		    	    }
		    	    return true;
			}
});
  });
  function closewin(){
	  getTopWin(window).closejBox("add-resource-view-config");
  }

 
  
  </script>
  </head>
  
  <body class="padding-8">
    	<form action="" id="myform" name="myform" method="post">
    		<table  class="table_eidt">
    			<tr>
	    			<td class="td_left" width="65px"><span class="span_alert">*</span>视图名称</td>
	    			<td class="td_right"><input type="text" name="name" id="name" style="width:200px;" class="input_text">
	    			<span id="nameTip" style="width:160px"></span></td>
    			</tr>
    			<tr>
	    			<td class="td_left"><span class="span_alert">*</span>打开层数</td>
	    			<td class="td_right"><input type="text" name="expandLevel" id="expandLevel" value="2" style="width:200px;" class="input_text">
	    			<span id="expandLevelTip" style="width:160px"></span></td>
    			</tr>
    		</table>
    		<div align="center" style="margin-top:5px;">
	    		<input type="submit" id="button" name="button" value="保存" class="btn-4">
	    		<input type="reset" class="btn-4">
	    		<input type="button" value="取消" onclick="closewin();" class="btn-4">
    		</div>
    		
    	</form>
  </body>
</html>
